<?php
//dezend by http://www.yunlu99.com/ QQ:270656184
defined('BASEPATH') || exit('No direct script access allowed');
?><link rel="stylesheet" href="/static/css/money.css">
<div class="user-body">
  	<div class="body-content">
      <div class="body-title">
        <?php echo lang('money_coin_draw');?>      </div>

      <div class="coins">
      	
<?php
foreach ($coins as $v) {
?>      	<a 
<?php
	if ($coin['id'] == $v['id']) {
?>class="on"<?php
	}

?> href="<?php echo site_url('out/index');?>?cid=<?php echo $v['id'];?>" class="coin-tab"><?php echo $v['en_name'];?></a>
      	<?php
}

?>      	<div class="clear"></div>
      </div>

      <div class="form">
     	<form action="<?php echo site_url('out/insert');?>" method="post" id="form_id">
     	<input type="hidden" name="coin_id" value="<?php echo $coin['id'];?>">
      	<table cellspacing=0 cellpadding=0 border=0>
      		<tr><th><?php echo lang('money_out_enable');?>：</th><td><?php echo $xnb['num'];?></td></tr>
      		<tr><th><?php echo lang('money_out_address');?>：</th><td>
      		<select name="address_id">
      		
<?php
if ($address) {
?>      		
<?php
	foreach ($address as $v) {
?>      		<option value="<?php echo $v['id'];?>"><?php echo $v['code'];?></option>
      		<?php
	}

?>      		<?php
}
else {
?>      		<option value="0"><?php echo lang('money_out_address_no');?></option>
      		<?php
}

?>      		</select>
      		<a href="<?php echo site_url('channels/address');?>"><?php echo lang('money_out_address_add');?></a>
      		</td></tr>
      		<tr><th><?php echo lang('money_out_num');?>：</th><td><input type="text" name="num"><p><?php echo lang('money_out_num_warn');?></p></td></tr>
      		<tr><th><?php echo lang('money_out_fee');?>：</th><td id="fee">0.00</td></tr>
      		<tr><th><?php echo lang('money_out_real');?>：</th><td id="real_num">0.00</td></tr>
      		<tr><th><?php echo lang('money_out_paypwd');?>：</th><td><input type="password" name="paypwd"><p><?php echo lang('money_out_paypwd_warn');?></p></td></tr>
      		<tr>
		    <th><?php echo lang('user_mobile_code');?>：</th>
			<td><input type="text" name="mobile_captcha" class="captcha_txt" style="width:100px;"><p><?php echo lang('user_mobile_code_warn');?></p><a id="send" class="captcha_btn" style="height:22px;line-height:22px;"><?php echo lang('user_mobile_btn');?></a></td>
			</tr>
      		<tr><th></th><td class="warning"></td></tr>
      		<tr><th></th><td><button type="submit"><?php echo lang('money_next');?></button></td></tr>
      	</table>
      	</form>
      </div>
      
      <div class="notice">
      	<h3><?php echo lang('money_out_notice');?></h3>
      	<p><?php echo str_replace('
', '<br/>', $cfg['xnb_draw_notice']);?></p>
      </div>
      
      <script>
		$(function(){
			$('#form_id').checkForm();
			$('[name="num"]').xnb();
			$('[name="num"]').bind('keyup change',function(){
				var fee_rate = '<?php echo $cfg['xnb_draw_fee'];?>';
				var fee = Number($(this).val()) * Number(fee_rate) / 100;
				$('#fee').text(fee);
				$('#real_num').text(Number($(this).val()) - fee);
			});
			$('#send').sendMobile('<?php echo site_url('tool/mobile_safe');?>','','cn');
		})
      </script>
      
      <div class="list">
      	<h3><?php echo lang('money_out_list');?></h3>
      	<table cellspacing=0 cellpadding=0 border=0>
			<thead>
				<tr>
					<th>ID</th>
					<th><?php echo lang('money_out_date');?></th>
					<th><?php echo lang('money_out_num');?></th>
					<th><?php echo lang('money_out_fee');?></th>
					<th><?php echo lang('money_out_real');?></th>
					<th><?php echo lang('money_out_address');?></th>
					<th>
						<select id="status">
							<option value="-1" 
<?php
if ($status == '-1') {
?>selected<?php
}

?>><?php echo lang('money_out_status');?></option>
							<option value="0" 
<?php
if ($status == 0) {
?>selected<?php
}

?>><?php echo lang('money_out_wait');?></option>
							<option value="2" 
<?php
if ($status == 2) {
?>selected<?php
}

?>><?php echo lang('money_out_work');?></option>
							<option value="1" 
<?php
if ($status == 1) {
?>selected<?php
}

?>><?php echo lang('money_out_complete');?></option>
							<option value="3" 
<?php
if ($status == 3) {
?>selected<?php
}

?>><?php echo lang('money_out_rescinded');?></option>
							<option value="4" 
<?php
if ($status == 4) {
?>selected<?php
}

?>><?php echo lang('money_out_fail');?></option>
						</select>
					</th>
					<th><?php echo lang('money_out_action');?></th>
				</tr>
			</thead>
			<tbody>
			    
<?php
foreach ($list as $v) {
?>				<tr>
					<td><?php echo $v['id'];?></td>
					<td><?php echo date('Y-m-d H:i', $v['add_time']);?></td>
					<td><?php echo $v['num'];?></td>
					<td><?php echo $v['fee'];?></td>
					<td><?php echo $v['real_num'];?></td>
					<td><?php echo $v['address']['code'];?></td>
					<td>
						
<?php
	if ($v['status'] == 0) {
?><?php echo lang('money_out_wait');?><?php
	}

?>						
<?php
	if ($v['status'] == 1) {
?><?php echo lang('money_out_complete');?><?php
	}

?>						
<?php
	if ($v['status'] == 2) {
?><?php echo lang('money_out_work');?><?php
	}

?>						
<?php
	if ($v['status'] == 3) {
?><?php echo lang('money_out_rescinded');?><?php
	}

?>						
<?php
	if ($v['status'] == 4) {
?><?php echo lang('money_out_fail');?><?php
	}

?>					</td>
					<td>
<?php
	if ($v['status'] == 0) {
?><a href="javascript:void(0);" class="cancel-btn" data-id="<?php echo $v['id'];?>">撤销</a><?php
	}

?></td>
				</tr>
				<?php
}

?>			</tbody>
		</table>
		<div class="page">
		  <?php echo $page;?>		</div>
		
<?php
if (!$list) {
?>		<div class="not-list">
			<i class="fa fa-ban"></i>
			<span><?php echo lang('user_not_list');?></span>
		</div>
		<?php
}

?>		<div class="clear"></div>
      </div>
    </div>
  </div>
  <div class="clear"></div>
</div>
<script>
$(function(){
	$('.cancel-btn').single('<?php echo site_url('out/cancel');?>');
	$('#status').change(function(){
		$.cookie('select_status',$(this).val());
		location.reload();
	});
});
</script>